<?php

namespace App\Models\MainDB\WarOrder;

use Illuminate\Database\Eloquent\Model;

class WarOrderUserReward extends Model
{
    protected $table = 'ln_war_order_user_reward';

    protected $fillable = [
        'id',
        'user_id',
        'war_order_id',
        'level',
        'war_order_reward_id',
        'type',//1礼物1；2礼物2；3礼物3
        'status',//1已领取0未领取
        'add_time',
        'receive_time',
    ];

    public $timestamps = false;

    public function getUserRewardList($user_id, $war_order_id)
    {
        return $this->where(['user_id' => $user_id, 'war_order_id' => $war_order_id])->get();
    }

    public function getUserRewardMap($user_id, $war_order_id)
    {
        $data = [];
        $list = $this->getUserRewardList($user_id, $war_order_id);
        foreach ($list as $value) {
            $data[$value->war_order_reward_id] = $value->status;
        }

        return $data;
    }
}
